<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	
	<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
	<script src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.min.js"></script>
	<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
	<style type="text/css">
	.site-form{
		margin-top:150px;
	}
	#button{
		margin-left: 90px;
	}
	</style>
</head>
<body>
				<div class="row" id="app" style="margin-top: 100px;">
					<div class="col-sm-4" ></div>
					<div class="col-sm-4" >
						 
				            <div class="form-group">
				              <label for="old-password">旧密码</label>
				              <input type="password" class="form-control" v-model="oldpwd" name="oldpwd" id="old-password" placeholder="输入账号的原登录密码">
				            </div>
				            <div class="form-group">
				              <label for="new-password">新密码</label>
				              <input type="password" class="form-control" v-model="newpwd" name="newpwd" id="new-password" placeholder="输入新的密码">
				            </div>
				            <div class="form-group">
				              <label for="confirm-password">确认新密码</label>
				              <input type="password" class="form-control" v-model="repwd" name="confirmpwd" id="confirm-password" placeholder="请再次输入新密码">
				            </div>
				            <button @click="submit()" class="btn btn-primary" id="button">修改密码</button>
				          
						
					</div>
					<div class="col-sm-4" ></div>
				</div>
				
<script type="text/javascript">
	new Vue({
		el:"#app",
		data:{
			oldpwd:'',
			newpwd:'',
			repwd:''
		},
		methods:{
			submit:function(){
				var oldpwd = this.oldpwd;
				var newpwd = this.newpwd;
				var repwd = this.repwd;
				if(newpwd!=repwd){
					alert("两次输入的新密码不一致，请重新输入");
					return;
				}
				axios.get("user/updatepassword?oldpwd="+oldpwd+"&newpwd="+newpwd).then(res => {
					if(res.data!=-1){
						alert("修改密码成功");
						//刷新页面上的数据
						location.reload();
					}else{
						alert("原密码不正确，请重新输入");
					}
					
				})
			}
		
			
		}
	});
	</script>				
</body>
</html>
